﻿using System.Collections.Generic;
using BlueDot.Data.Core;

namespace CreateDatabaseFromEntities.Data.Entities
{
    public class Blog : Entity
    {
        #region Fields

        public const string BlogIDColumnName = "BlogID";
        public const string DescriptionColumnName = "Description";
        public const string PostsColumnName = "Posts";
        public const string TitleColumnName = "Title";
        public const string UserIDColumnName = "UserID";

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the blog ID.  
        /// IsUniqueKey: Defines this property as the UniqueKey (Primary Key)
        /// IsGenerated: Defines this property is gernerated by the database. Since
        /// the dataType is an int the DB provider will create the field as an Identity field
        /// </summary>
        /// <value>The blog ID.</value>
        [Property(IsUniqueKey = true, IsGenerated = true)]
        public int BlogID { get; set; }

        /// <summary>
        /// Gets or sets the description.
        /// Note that the size has not been defined.  By default it will be created with a max length of 255
        /// </summary>
        /// <value>The description.</value>
        [Property(IsRequired = true)]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the posts.
        /// </summary>
        /// <value>The posts.</value>
        [Relationship(RelationshipType = RelationShipTypes.OneToMany)]
        public List<Post> Posts { get; set; }

        /// <summary>
        /// Gets or sets the title.
        /// Size: Defines the length of the field when the database is created.
        /// IsRequried: Defines this as a required property and will be set to NOT NULL in the database
        /// </summary>
        /// <value>The title.</value>
        [Property(MaxLength = 50, IsRequired = true)]
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the blog ID.
        /// You do not need to reference the actual entity but its PK. If you reference the
        /// primitive type instead of the Entity you must supply the RelatedEntityType
        /// </summary>
        /// <value>The blog ID.</value>
        [Relationship(RelationshipType = RelationShipTypes.OneToMany, RelatedEntityType = typeof (User))]
        public int UserID { get; set; }

        #endregion
    }
}